-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Set process.env.LOG_LEVEL
to null
in webpack config + Buffer polyfill
#115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
null
in webpack configprocess.env.LOG_LEVEL
to null
in webpack config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for testing thoroughly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work investigating! Do you want to patch the version in this PR too to publish the fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

I'm still getting Buffer is not defined, so I don't think this is the full solution. It looks like it's coming from https://github.com/Eppo-exp/js-sdk-common/blob/0587b36dc4547a29fbfd351ad3a46954d3263684/src/events/sdk-key-decoder.ts#L10. I think we need to update that file with the decodeBase64
function in src/obfuscation.ts
.
Yup i'll bump the version and release |
ohh I see the error surfaces when you call |
I'm using the |
process.env.LOG_LEVEL
to null
in webpack configprocess.env.LOG_LEVEL
to null
in webpack config + Buffer polyfill
Bumped shared sdk, retested everything, good to go! |
// Make sure any usages of Buffer use the polyfill in the browser | ||
new webpack.ProvidePlugin({ | ||
Buffer: ['buffer', 'Buffer'], | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is in theory no longer necessary now that we replaced Buffer with js-base64 in the common sdk, but I think it's worth leaving it here to cover our basis in case something else slips in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works now!
labels: mergeable
Fixes: #issue
Motivation and Context
Fix
process is not defined
errorDescription
Eppo-exp/js-sdk-common#136 introduced a change to
applicationLogger
that added a check forprocess.env.LOG_LEVEL
.This doesn't work on the browser because
process
only exists in the Node environment.Although there's a tricky reason why the original
(process.env.NODE_ENV === 'production' ? 'warn' : 'info')
expression didn't already fail, which is that webpack resolves the entire expression to simplywarn
since it resolvesprocess.env.NODE_ENV
toproduction
at build time.I've worked around it by doing a similar preprocessing step for
LOG_LEVEL
by adding awebpack.DefinePlugin
to the webpack config that sets it to null.This causes webpack to simplify the entire line to just
level: "warn"
.How has this been tested?
yarn webpack
Inspect the generated file
dist/eppo-sdk.js
. It should have a line line like below:Create a
index.html
file with the following contents:Load this page in the browser and there should be no errors in the dev tools console.